

import 'package:flutter/material.dart';

import 'package:flutter/widgets.dart';


void main(List<String> args) {
  runApp(MyApp());
}
List listData=[
      {
          "title": 'Candy Shop',
          "author": 'Mohamed Chahin',
          "imageUrl": 'https://www.itying.com/images/flutter/1.png',
      },
       {
          "title": 'Childhood in a picture',
          "author": 'Google',
          "imageUrl": 'https://www.itying.com/images/flutter/2.png',
      },
      {
          "title": 'Alibaba Shop',
          "author": 'Alibaba',
          "imageUrl": 'https://www.itying.com/images/flutter/3.png',
      },
      {
          "title": 'Candy Shop',
          "author": 'Mohamed Chahin',
          "imageUrl": 'https://www.itying.com/images/flutter/4.png',
      },
       {
          "title": 'Tornado',
          "author": 'Mohamed Chahin',
          "imageUrl": 'https://www.itying.com/images/flutter/5.png',
      },
      {
          "title": 'Undo',
          "author": 'Mohamed Chahin',
          "imageUrl": 'https://www.itying.com/images/flutter/6.png',
      },
      {
          "title": 'white-dragon',
          "author": 'Mohamed Chahin',
          "imageUrl": 'https://www.itying.com/images/flutter/7.png',
      },
       {
          "title": 'Candy Shop',
          "author": 'Mohamed Chahin',
          "imageUrl": 'https://www.itying.com/images/flutter/1.png',
      },
       {
          "title": 'Childhood in a picture',
          "author": 'Google',
          "imageUrl": 'https://www.itying.com/images/flutter/2.png',
      },
      {
          "title": 'Alibaba Shop',
          "author": 'Alibaba',
          "imageUrl": 'https://www.itying.com/images/flutter/3.png',
      },
      {
          "title": 'Candy Shop',
          "author": 'Mohamed Chahin',
          "imageUrl": 'https://www.itying.com/images/flutter/4.png',
      },
       {
          "title": 'Tornado',
          "author": 'Mohamed Chahin',
          "imageUrl": 'https://www.itying.com/images/flutter/5.png',
      },
      {
          "title": 'Undo',
          "author": 'Mohamed Chahin',
          "imageUrl": 'https://www.itying.com/images/flutter/6.png',
      },
      {
          "title": 'white-dragon',
          "author": 'Mohamed Chahin',
          "imageUrl": 'https://www.itying.com/images/flutter/7.png',
      }

  ];
//自定义组件
class MyApp extends StatelessWidget {
  const MyApp({Key key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("flutter demo"),
        ),
        body: LaugoutDemo(),
      ),
      theme: ThemeData(
          // brightness: Brightness.light,
          primarySwatch: Colors.yellow),
    );
  }
}

class LaugoutDemo extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 500.0,
      width: 400.0,
      color: Colors.pink,
      padding: EdgeInsets.all(10.0),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,//相对于外层得容器
        mainAxisSize: MainAxisSize.max,
        crossAxisAlignment: CrossAxisAlignment.start, //相对于外层得容器
        children: <Widget>[
          IconConatainer(Icons.home,size: 40.0,color: Colors.yellow),
          IconConatainer(Icons.home,size: 40.0,color: Colors.white),
          IconConatainer(Icons.home,size: 40.0,color: Colors.blue),
        ],
      )
    );

  }
}

class IconConatainer extends StatelessWidget {

  double size = 40.0;
  Color color = Colors.white24;
  IconData icon;
  IconConatainer(this.icon,{Key key,this.size,this.color}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 100,
      width: 100,
      alignment: Alignment.center,
      decoration: BoxDecoration(
        color: Colors.red
      ),
      child: Center(
        child: Icon(this.icon,size: this.size,color: this.color),
      )
    );
  }
}
